const { ccclass } = cc._decorator;

@ccclass
export default class UrlMgr {
    private _urlMap;
    private requestUrl;
    constructor() {
        this._urlMap = new Map();
        this.requestUrl = {
            GetSystemConfig: {
                uri: 'config',
                enqueue: true
            },
            AutoLogin: {
                uri: 'login/auto_submit',
                enqueue: true
            },
            TouristLogin: {
                uri: 'login/tourists_submit',
                enqueue: true
            },
            WeChatLogin: {
                uri: 'login/wechat_submit',
                enqueue: true
            },
            BindWeChat: {
                uri: 'login/tourists_bind_wechat',
                enqueue: true
            },
            GetGameConfig: {
                uri: 'behaviors/config',
                enqueue: true
            },
            UserInfo: {
                uri: 'behaviors/info',
                enqueue: true
            },
            Reco_Switch: {
                uri: 'behaviors/reco_switch',
                enqueue: true
            },
            ScrollMsg: {
                uri: 'behaviors/scroll_msg',
                enqueue: true
            },
            Logoff: {
                uri: 'login/user_cancel',
                enqueue: true
            },
            AgreementReport: {
                uri: 'agreement_report',
                enqueue: false
            },
            shuMengReport: {
                uri: 'shumeng_report',
                enqueue: false
            },
            GetClockTaskList: {
                uri: 'task/get_clock_task_list',
                enqueue: true
            },
            SaveClockTask: {
                uri: 'task/save_clock_task_reward',
                enqueue: true
            },
            GetExtractInfo: {
                uri: 'extract/extract_info',
                enqueue: true
            },
            ExtractCashRecord: {
                uri: 'extract/extract_cash_record',
                enqueue: true
            },
            TravelExtractInfo: {
                uri: 'extract/travel_extract_info',
                enqueue: true
            },
            ExtractCash: {
                uri: 'extract/extract_cash',
                enqueue: true
            },
            VideoGetGold: {
                uri: 'extract/video_gold',
                enqueue: true
            },
            TravelInfo: {
                uri: 'game/get_traval_info',
                enqueue: true
            },
            VideoReward: {
                uri: 'game/video',
                enqueue: true
            },
            OutSideGuideStep: {
                uri: 'game/step_record',
                enqueue: true
            },
            MatchGameStart: {
                uri: 'game/start_game',
                enqueue: true
            },
            MatchGameVideo: {
                uri: 'game/game_video',
                enqueue: true
            },
            UseProp: {
                uri: 'game/props',
                enqueue: true
            },
            MatchGameSubMit: {
                uri: 'game/submit_game',
                enqueue: true
            }
        };
    }

    static _instance;

    static getInstance() {
        return UrlMgr._instance ? UrlMgr._instance : (UrlMgr._instance = new UrlMgr());
    }

    getUrl(e) {
        const t = this._urlMap.get(e);
        if (t == null) {
            const baseUrl = 'your_base_url'; // 替换为你的基础URL
            let t = baseUrl + this.getUri(e);
            this._urlMap.set(e, t);
        }
        return t;
    }

    getUri(e) {
        return this.requestUrl[e] ? this.requestUrl[e].uri : '';
    }

    needEnqueue(e) {
        return !!this.requestUrl[e] && this.requestUrl[e].enqueue;
    }
}
